<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>
	<script type="text/javascript">
		$(function () {
            $('#myUserDatagrid').datagrid({
                url:'${pageContext.request.contextPath}/user/selectCmfzUserDatagrid',
                method:"get",
                pagination:true,
                columns:[[
                    //一旦加上复选框属性，页面展示不出来效果，刷新后表格对不齐
					{field:'恶心',title:'复选框',checkbox:true},
                    {field:'userId',title:'用户编号',width:100,align:"center"},
                    {title:"用户头像",field:"userImage" ,
                        formatter: function (value, row, index) {
                            return "<img width='60px' height='45px' src='${pageContext.request.contextPath}" + row.userImage + "'/>";
                        }},
                    {field:'userName',title:'用户名字',width:100,align:"center"},
                    {field:'userNickname',title:'用户法号',width:100,align:"center"},
                    {field:'userSex',title:'用户性别',width:100,align:"center"},
                    {field:'userProvince',title:'用户省份',width:100,align:"center"},
                    {field:'userCity',title:'用户城市',width:100,align:"center"},
                    {field:'guruId',title:'所属上师',width:150,align:"center",
                        formatter: function (value, row, index) {
                            return row.cmfzGuru.guruName;
                        }},
                    {field:'userCreateDate',title:'创建日期',width:150,align:"center"},
                    {field:'userAutograph',title:'用户签名',width:150,align:"center"}
                ]],
                toolbar: '#myUserTooBar'
            });
		});

		// 批量删除用户
        function doDeleteSomeUsers() {
            var allSelectionRows=$("#myUserDatagrid").datagrid("getSelections");
            if(allSelectionRows.length==0){
                alert("请选择要删除的数据！");
            }else{
                var isConfirm=confirm("请确认是否删除？");
                if(isConfirm){
                    var allIds=new Array(allSelectionRows.length);
                    for(var i=0;i<allIds.length;i++){
                        allIds[i]=allSelectionRows[i].userId;
                    }
                    //发送ajax请求
                    $.ajax({
                        url:"${pageContext.request.contextPath}/user/deleteSomeUsers",
                        data:"ids="+allIds,
                        success:function(data){
                            //删除成功，刷新页面
                            if(data.isDelete){
                                $("#myUserDatagrid").datagrid("reload");
                            }else{
                                alert("删除失败，请确认！");
                            }
                        }
                    })
                }
            }
        }

	</script>
	<div id="myUserTooBar">
		<a class="easyui-linkbutton" onclick="doDeleteSomeUsers()">删除</a>
	</div>
	<table id="myUserDatagrid"></table>
